//
//  SEIncomeBankViewController.swift
//  SmartEyeForDoctor
//
//  Created by qdsg on 2021/5/5.
//

import UIKit

class SEIncomeBankViewController: SEBaseViewController {

    @IBOutlet weak var tableView: UITableView! {
        didSet {
            tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 15))
            tableView.tableFooterView = tableFooterView
            tableView.keyboardDismissMode = .onDrag
            tableView.register(SEInquirySettingFeeCell.nibForCell(), forCellReuseIdentifier: SEInquirySettingFeeCell.reuseIdentifier())
        }
    }

    private lazy var tableFooterView: UIView = {
        let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.screenWidth, height: 50 + 48 + 25))
        let btnView = SEConfirmBtnView(frame: CGRect(x: 15, y: 50, width: UIScreen.screenWidth - 30, height: 48))
        btnView.delegate = self
        btnView.title = "更换结算账户"
        view.addSubview(btnView)
        return view
    }()

    var viewModel = SEIncomeBankViewModel()

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "结算账户"
        addEndEditingTap()
        // Do any additional setup after loading the view.
    }

}

// MARKL: - UITableViewDataSource, UITableViewDelegate

extension SEIncomeBankViewController: UITableViewDataSource, UITableViewDelegate {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: SEInquirySettingFeeCell.reuseIdentifier(), for: indexPath) as! SEInquirySettingFeeCell
        cell.updateData(viewModel.cellModel, indexPath: indexPath)
        return cell
    }

}

// MARK: - SEConfirmBtnViewDelegate

extension SEIncomeBankViewController: SEConfirmBtnViewDelegate {
    func confirmBtnViewAction(view: SEConfirmBtnView) {
        let vc = SEIncomeBankAddViewController()
        navigationController?.pushViewController(vc, animated: true)
    }
}
